#!/usr/bin/python3

import sys, os, requests

# URL = "http://localhost:6370"
URL = "http://100.75.54.12:6370"
file = sys.argv[1]
with open(file, "rb") as pic:
    result = requests.post(URL + "/OCR", files={'pic': pic.read()}).json()

if result['code'] != 0:
    print("error currs", file=sys.stderr)

data = result['meta']

# data中的信息很多, 下面只将识别的文字挑出来合并
text = "\n".join(it[1][0] for it in data)
print(text)
